<template>
    <div>
        <h1>A组件</h1>
        <ul v-for="item in list" :key="item.id" >
            <li>{{item.name}}</li>
        </ul>
        <button @click="changeParentName" >点击我发送值给父组件</button>
    </div>
</template>

<script>
export default {
  name: "A",
  props: {
    list: Array
  },
  data(){
    return{
     
    }
  },
  methods:{
    init(){
        this.list.forEach(item=>{
            console.log(JSON.stringify(item));
        });
    },
    changeParentName(){
        this.$emit('changeParentName','传递给父组件的值')
    }
  },
  mounted(){
    this.init();
  }
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>

</style>
